/** A simple RMI server

I.  Server Components

  A RMI server program 
	A remote server program consist three parts, remote information,
	remote implementation and server application.


	1. The first part is remote server program interface.
	2. The second part is the remote server program implementation,
	3. The third part is server application, and it is optional.


  RMI Server Interface:
	Each remote server program must have a remote interface. The
    interface will

      - Extends java.rmi.Remote interface and Remote interface has no method.
      - RMI server program interface list all methods callable from
	remote client program.
      - Every method in the interface must throw a RemoteException.

  RMI Server Implementation:

      To implement your remote server interface you define, you declare a class that 

      - extends java.rmi.server.RemoteObject or its subclass (RemoteServer class). 
	RemoteServer class has two subclasses java.rmi.server.UnicastRemoteObject
	and java.rmi.server.Activatable.
      - implements the RMI server program interface you defined before.

  RMI Application
      - Define a remote server object.
      - Create a remote server object registry by eiher rmiregistry command and a Naming.rebind()
        statatment, or by create registry and bind() statements in application program.
      - Bind the object to a unique name in a namespace.
      - The RMI application may or may not be in a separate source file.
	You can add a main() in RMI server implementation class and
	define remote server object and bind object in main().

II. Compilation

  1. After the interface and the implementation is written, compile implementation
and thus, compile the interface automatically.

  2. After the server implementation is compiled, run server utilty rmic to
generate stub used in the client and skeleton used on the server-side.

  3. The stub and skeleton provide high level communication between remote client
and remote server.

  4. You need to move RMI server interface and RMI server implementation stub to 
a place where the RMI client program can access. 
 
  5. Run "rmiregistry [port] &" and run java application "java SimpleServer1Impl &". The
     "rmiregistry [port] &" should be omitted if you start registry in application (main)
     at a specified port, and bind the registry with special port with server name.
     See below for details.
      
  6. Run client program on client machine.

III. Registry - Object that bind remote server to a specific port on current machine.

  A registry is needed to bind/link a remote server object to a specified port. A registry can
  be created in two different ways and is used to bind remove server program to a port.

  1. Run "rmiregistry &", and then call "Naming.rebind() in Java server implementation program:
  	Naming.rebind("//localhost/RMIServerName", rmiseverObject), or 
  	Naming.rebind("//localhost:port/RMIServerName", rmiserverObject)

	If port number is omitted, 1099 is used in eitehr rmiregistry command and rebind() call.

  2. Add the following two statement in the RMI server implementation progra

	Registry reg = LocateRegistry.createRegistry( 2111 );
	reg.rebind( MessageReceiver.serverName,  svrObj);

     The first statement create a registry with specified port (2111 in this case), and the
     second statement bind a server object to poart.

     On some machine rmiregistry port can be omitted and on other, you have to run rmiregistry first.
*/

import java.rmi.*;
import java.rmi.server.*;

public interface SimpleServer1 extends Remote {
    // This name defined where will be used by RMI client to 
    // refer the SimpleSever1Impl object.
    public void write(String clientName, String msg ) throws RemoteException;
}
